#include <iostream>
#include <cstring>
#include <queue>
#include <map>
#include <vector>
#include <string.h>
using namespace std;

string a;
string b;

int dp[2010][2010];

int main()
{
    cin >> a >> b;
    int len1 = a.size();
    int len2 = b.size();

    //边界
    for (int i = 1; i <= len1; i++)
        dp[i][0] = i;
    for (int i = 1; i <= len2; i++)
        dp[0][i] = i;

    for (int i = 1; i <= len1; i++)
    {
        for (int j = 1; j <= len2; j++)
        {
            if (a[i - 1] == b[j - 1])
            { // a的第i个字符和b的第j个字符相等
                dp[i][j] = dp[i - 1][j - 1];
            }
            else
                dp[i][j] = min(min(dp[i][j - 1] + 1, dp[i - 1][j] + 1), dp[i - 1][j - 1] + 1);
        }
    }
    cout << dp[len1][len2] << endl;
    system("pause");
    return 0;
}